package com.litong.rms.action;

import java.util.List;

import com.litong.rms.bean.Function;
import com.litong.rms.service.AuthService;
import com.litong.rms.service.FunctionService;

public class FunctionAction extends BaseAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private Function function;
	
	private FunctionService functionService;
	
	private AuthService authService;
	
	private String functionId;
	
	private List<Function> functionList;
	
	
	
	/*获取功能列表*/
	public String list(){
		functionList = functionService.getFunctionList();
		return SUCCESS;
	}
	
	/*删除功能*/
	public String deleteFunction(){
		function = new Function();
		function.setFunctionId(Integer.parseInt(functionId));
		
		authService.deleteAuth("function", Integer.parseInt(functionId));
		functionService.deleteFunction(function);
		return list();
	}
	
	/*添加功能*/
	public String addFunction(){
		functionService.addFunction(function);
		return SUCCESS;
	}
	
	/*根据ID查询功能*/
	public String findUpdateFunction(){
		function = functionService.findById(Integer.parseInt(functionId));
		return SUCCESS;
	}
	
	/*更新功能*/
	public String updateFunction(){
		functionService.updateFunction(function);
		return	SUCCESS;
	}
	
	
	public Function getFunction() {
		return function;
	}
	public void setFunction(Function function) {
		this.function = function;
	}
	public FunctionService getFunctionService() {
		return functionService;
	}
	public void setFunctionService(FunctionService functionService) {
		this.functionService = functionService;
	}
	public String getFunctionId() {
		return functionId;
	}
	public void setFunctionId(String functionId) {
		this.functionId = functionId;
	}
	public List<Function> getFunctionList() {
		return functionList;
	}
	public void setFunctionList(List<Function> functionList) {
		this.functionList = functionList;
	}

	public void setAuthService(AuthService authService) {
		this.authService = authService;
	}

	public AuthService getAuthService() {
		return authService;
	}
	
}
